/*
 * Decompiled with CFR 0.150.
 * 
 * Could not load the following classes:
 *  cn.hutool.core.util.ReUtil
 *  cn.hutool.core.util.StrUtil
 */
package com.gys.common.util;

import cn.hutool.core.util.ReUtil;
import cn.hutool.core.util.StrUtil;
import java.math.BigDecimal;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ValidationUtil {
    public static boolean checkNumberStr(String str) {
        if (StrUtil.isBlank((CharSequence)str)) {
            return true;
        }
        return ReUtil.isMatch((String)"^[-\\+]?[\\d]*$", (CharSequence)str);
    }

    public static boolean checkPositiveInteger(String str) {
        if (StrUtil.isBlank((CharSequence)str)) {
            return true;
        }
        String theOne = str.substring(0, 1);
        if ("0".equals(theOne) || "-".equals(theOne)) {
            return false;
        }
        return ReUtil.isMatch((String)"[0-9]*", (CharSequence)str);
    }

    public static boolean checkNumber(String str) {
        if (StrUtil.isBlank((CharSequence)str)) {
            return true;
        }
        try {
            new BigDecimal(str);
        }
        catch (Exception e) {
            return false;
        }
        return true;
    }

    public static boolean checkPositiveNumber(String str) {
        if (StrUtil.isBlank((CharSequence)str)) {
            return true;
        }
        try {
            BigDecimal number = new BigDecimal(str);
            if (number.intValue() < 0) {
                return false;
            }
        }
        catch (Exception e) {
            return false;
        }
        return true;
    }

    public static boolean checkAmount(String str) {
        String reg_money = "\\d+(\\.\\d{1,4})?";
        Pattern pattern = Pattern.compile(reg_money);
        Matcher matcher = pattern.matcher(str);
        boolean ismatch = matcher.matches();
        return ismatch;
    }

    public static boolean checkPositiveNumberGtZero2F(String str) {
        if (StrUtil.isBlank((CharSequence)str)) {
            return true;
        }
        if (str.split("\\.").length == 2 && str.split("\\.")[1].length() > 2) {
            return false;
        }
        try {
            BigDecimal number = new BigDecimal(str);
            if (number.doubleValue() <= 0.0) {
                return false;
            }
        }
        catch (Exception e) {
            return false;
        }
        return true;
    }

    public static boolean checkPositiveNumber2F(String str) {
        if (StrUtil.isBlank((CharSequence)str)) {
            return true;
        }
        if (str.split("\\.").length == 2 && str.split("\\.")[1].length() > 2) {
            return false;
        }
        try {
            BigDecimal number = new BigDecimal(str);
            if (number.doubleValue() < 0.0) {
                return false;
            }
        }
        catch (Exception e) {
            return false;
        }
        return true;
    }

    public static boolean checkPositiveNumberGtZero(String str) {
        if (StrUtil.isBlank((CharSequence)str)) {
            return true;
        }
        try {
            BigDecimal number = new BigDecimal(str);
            if (number.intValue() <= 0) {
                return false;
            }
        }
        catch (Exception e) {
            return false;
        }
        return true;
    }

    public static boolean checkNumberOrChar(String str) {
        if (StrUtil.isBlank((CharSequence)str)) {
            return true;
        }
        return ReUtil.isMatch((String)"^[a-z0-9A-Z]+$", (CharSequence)str);
    }

    public static boolean checkPhone(String str) {
        return ReUtil.isMatch((String)"^((13[0-9])|(15[^4,\\D])|(18[0-9]))\\d{8}$", (CharSequence)str);
    }
}

